home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / dates3.com / TESTDATE.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1989-05-11  |  2.0 KB  |  64 lines

  1. {
  2. Demo program to test the DATES3 unit.  Has minimal error checking for
  3. all keyboard input to the program.
  4. }
  5.  
  6. program testdate;
  7.  
  8. uses dates3,dos;
  9.  
  10. var
  11.   month,day,year:word;
  12.   months,days,years:integer; input:real;
  13.   datenum:longint;
  14.   i:byte; buff:string;
  15.  
  16.  
  17. begin
  18.   writeln;
  19.   repeat
  20.     writeln('Enter numbers only for ALL input to program.');
  21.     write('Enter Month: ');
  22.     readln(input);
  23.     month:=abs(trunc(input));
  24.     write('Enter Day: ');
  25.     readln(input);
  26.     day:=abs(trunc(input));
  27.     write('Enter Year: ');
  28.     readln(input);
  29.     year:=abs(trunc(input));
  30.   until validdate(month,day,year);
  31.   datenum:=datenumber(month,day,year);
  32.   writeln('The Datenumber for ',month,'/',day,'/',year,' is: ',datenum);
  33.   writeln('The values of the 3 bytes in the sortable string are:');
  34.   buff:=numstring(datenum);
  35.   for i:=1 to 3 do
  36.     writeln('Byte #',i,': ',ord(buff[i]));
  37.   writeln('Reconstructed Datenumber from sortable string: ',stringnum(buff));
  38.   write('The reconstructed date for that datenumber is: ');
  39.   numberdate(datenum,month,day,year);
  40.   writeln(month,'/',day,'/',year);
  41.   writeln('Day of week number is: ',daynumber(datenum));
  42.   writeln('The day is: ',daystring(daynumber(datenum)));
  43.   writeln('The month is: ',monthstring(month));
  44.   writeln('Todays datenumber is: ',today);
  45.   if datenum<=today then
  46.     writeln('Age today if born on ',month,'/',day,'/',year,' is ',agetoday(datenum))
  47.   else
  48.     writeln('NO AGE - Date is after today');
  49.   write('Increase/Decrease Months by: ');
  50.   readln(input);
  51.   months:=trunc(input);
  52.   write('Increase/Decrease Days by: ');
  53.   readln(input);
  54.   days:=trunc(input);
  55.   write('Increase/Decrease Years by: ');
  56.   readln(input);
  57.   years:=trunc(input);
  58.   writeln('You selected: M=',months,' D=',days,' Y=',years);
  59.   datenum:=bumpdate(datenum,months,days,years);
  60.   writeln('New datenum for added/subtracted MDY is: ',datenum);
  61.   numberdate(datenum,month,day,year);
  62.   writeln('The NEW date with added/subtracted MDY is: ',month,'/',day,'/',year);
  63. end.
  64.